package com.woniu.service.bean;

import com.woniu.util.ApplicationContextHolder;
import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class AddEarnings {

    public static final String BUY="买入";
    public static final String SELL="卖出";
    public static final String TX="提现";

    private Integer id;
    private String dealTime;  //交易时间
    private String dealType; //交易类型
    private Integer userId; //用户id
    private BigDecimal dealPrice; //金额
    private BigDecimal dealCharge; //手续费
    private String productType; //产品类型
    private AddEarningsHandler handler;

    public AddEarnings() {
        this.handler = ApplicationContextHolder.getApplicationContext().getBean(AddEarningsHandler.class);
    }

    public AddEarnings(String dealTime, String dealType, Integer userId, BigDecimal dealPrice, BigDecimal dealCharge, String productType) {
        this();
        this.dealTime = dealTime;
        this.dealType = dealType;
        this.userId = userId;
        this.dealPrice = dealPrice;
        this.dealCharge = dealCharge;
        this.productType = productType;
    }

    public void execute() {
        handler.action(this);
    }

}
